class Solution(object):
    def numOfPairs(self, nums, target):
        n = len(nums)
        ans = 0
        for i in range(n):
            for j in range(n):
                if i != j:
                    if nums[i] + nums[j] == target:
                        ans += 1
        return ans